﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class Manage_CG_GiftProductPriceSpanOperate : System.Web.UI.Page
{
    private string act = Utils.RQ_str("act").ToLower();
    private int id = Utils.RQ_int("id");
    protected void Page_Load(object sender, EventArgs e)
    {
        clsAdmin adm = clsAdmin.getCookieAdmin();
        if (adm == null)
        {
            Utils.WrAlertGo("您尚未成功登陆，请成功登陆后再进行正常操作！", "../Login.aspx");
        }

        if (!this.IsPostBack)
            bindData();
        bindContrl();
    }

    private void bindContrl()
    {

    }

    private void bindData()
    {
        if (act == "edit")
        {
            ltMgTitle.Text = "修改产品价格分类";
            ltPathTitle.Text = "[修改产品价格分类]";
            ltOperTitle.Text = "修改产品价格分类";
            clsGiftProductPriceSpan cls = new clsGiftProductPriceSpan(id);
            tbxGiftProductPriceSpanName.Text = cls.GiftProductPriceSpanName;
            tbxGiftProductPriceSpanOrder.Text = cls.GiftProductPriceSpanOrder.ToString();
            btnSave.Text = " 修 改 ";
        }
        else
        {
            ltMgTitle.Text = "添加产品价格分类";
            ltPathTitle.Text = "[添加产品价格分类]";
            ltOperTitle.Text = "添加产品价格分类";
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string name = tbxGiftProductPriceSpanName.Text.Trim();
        string code = tbxGiftProductPriceSpanOrder.Text.Trim();
        if (name == "" || code == "")
        {
            Utils.WrAlertGoBack("标注*号为必填不可为空！");
        }
        clsGiftProductPriceSpan cls = new clsGiftProductPriceSpan(id);
        cls.GiftProductPriceSpanName = name;
        try
        {
            cls.GiftProductPriceSpanOrder = Convert.ToInt32(code);
        }
        catch (Exception)
        {
            Utils.WrAlertGoBack("价格排序值必须为数字！");
            throw;
        }
        if (act.ToLower() == "edit")
        {
            clsGiftProductPriceSpan.Update(cls);
        }
        else
        {
            clsGiftProductPriceSpan.Insert(cls);
        }
        Response.Redirect("GiftProductPriceSpanList.aspx", true);
    }
}